package com.zhenyi.liuxue.interceptor;

import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import com.jfinal.core.Controller;
import com.liuxue.common.model.LxSchool;

public class SchoolVisitiInterceptor implements Interceptor {

	@Override
	public void intercept(Invocation inv) {
		inv.invoke();
		Controller controller = inv.getController();
		Long id = controller.getParaToLong("id");
		if (id == null) {
			id = controller.getParaToLong("schoolId");
			if (id == null) {
				return;
			}
		}
		LxSchool info = LxSchool.dao.findById(id);
		if (info == null) {
			return;
		}
		info.setVisit(info.getVisit() + 1);
		info.update();
	}

}
